<template>
  <div class="HuikuiInfo el-card is-always-shadow el-card__body">
    <el-dialog
      title="回馈预览"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-crud
        ref="crud"
        :option="optionTableOne"
        :data="listTable">
      </avue-crud>
      <avue-crud
        ref="crud"
        :option="optionTable"
        :data="listTable">
        <template slot="menuLeft">
          LC系统数据对比与回馈
        </template>
        <template slot-scope="scope" slot="replySellAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replySellAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyInvestAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyInvestAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyFaretkAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyFaretkAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyComparativeSelltkAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyComparativeSelltkAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyComparativeInvestAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyComparativeInvestAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyComparativeFaretkAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyComparativeFaretkAmount"></el-input>
        </template>
      </avue-crud><br/><br/><br/>
      <avue-form :disabled="isReload" :option="option" v-model="formData" @submit="handleSubmit">
        <template  slot="qfReplyReason" slot-scope="scope">
          <el-select :disabled="showType==2" v-model="qfReplyReason" placeholder="请选择" style="width: 150px">
            <el-option
              v-for="(item,index) in qfReplyReasonList"
              :key="index"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="menuForm" >
          <el-button v-if="showType==1" type="primary" @click="handleSubmit" >确认</el-button>
          <el-button @click="closed" >返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {fenExYuangettoFixed,getSysDictItemListToDict,getStationName,getLineName} from "../../../api/subwayRat/commonCheck";
  import {updateSwAuConductorHierarchyAmountDifferen} from "../../../api/stationTiecketManager/shuJuXieChaGuanLi/BOM/CJ/BOMCengJiCY";
  import ElInput from "../../../../node_modules/element-ui/packages/input/src/input";
  export default {
    components:{
      ElInput
    },
    data() {
      return {
        qfReplyReason :'',
        replySellAmount:0,
        replyInvestAmount:0,
        replyFaretkAmount:0,
        replyComparativeSelltkAmount:0,
        replyComparativeInvestAmount:0,
        replyComparativeFaretkAmount:0,
        optionTableOne:{},
        listTable:[],
        optionTable:{},
        option:{},
        showType : 0,
        isReload:true,
        dialogVisible:true,
        formData:{},
        qfReplyReasonList:[],
        th:null
      }
    },
    created() {
      this.getOption();
      getSysDictItemListToDict({"type":"QF_REPLY_REASON"}).then((response)=>{
        this.qfReplyReasonList = response.data.data;
      });
    },
    methods: {
      async handleSubmit(){
        if(''==this.qfReplyReason){
          this.$message.warning("请选择回馈原因后提交！");
          return
        }
        let p = {
          id:this.formData.id,
          replySellAmount:this.replySellAmount,
          replyInvestAmount:this.replyInvestAmount,
          replyFaretkAmount:this.replyFaretkAmount,
          replyComparativeSelltkAmount:this.replyComparativeSelltkAmount,
          replyComparativeInvestAmount:this.replyComparativeInvestAmount,
          replyComparativeFaretkAmount:this.replyComparativeFaretkAmount,
          qfReplyReason:this.qfReplyReason,
          qfReplyDetail:this.formData.qfReplyDetail
        };
        await updateSwAuConductorHierarchyAmountDifferen(p).then((response)=>{
        });
        this.th.getList();
        this.closed();
      },
      recallShow(row,th){
        this.th = th;
        Object.assign(this.formData,row);
        this.listTable.push(row);
        this.replySellAmount = (row.replySellAmount/100).toFixed(2);
        this.replyInvestAmount = (row.replyInvestAmount/100).toFixed(2);
        this.replyFaretkAmount = (row.replyFaretkAmount/100).toFixed(2);
        this.replyComparativeSelltkAmount = (row.replyComparativeSelltkAmount/100).toFixed(2);
        this.replyComparativeInvestAmount = (row.replyComparativeInvestAmount/100).toFixed(2);
        this.replyComparativeFaretkAmount = (row.replyComparativeFaretkAmount/100).toFixed(2);
        this.qfReplyReason = row.qfReplyReason;
        if(2==this.showType){
          this.option.group[0].column[1].disabled = true;
        }
        if(1==row.comparativeType){
          this.optionTableOne.column[7].label = 'SC售票金额';
          this.optionTableOne.column[8].label = 'SC充值金额';
          this.optionTableOne.column[9].label = 'SC补票金额';
          this.optionTableOne.column[10].label = 'LC售票金额';
          this.optionTableOne.column[11].label = 'LC充值金额';
          this.optionTableOne.column[12].label = 'LC补票金额';
        }else{
          this.optionTableOne.column[7].label = 'LC售票金额';
          this.optionTableOne.column[8].label = 'LC充值金额';
          this.optionTableOne.column[9].label = 'LC补票金额';
          this.optionTableOne.column[10].label = 'ACC售票金额';
          this.optionTableOne.column[11].label = 'ACC充值金额';
          this.optionTableOne.column[12].label = 'ACC补票金额';
        }
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.showType = this.$parent.showType;
        if(1 == this.$parent.showType) {
          this.isReload = false;
        }
        this.optionTableOne={
          border: false,
          index: false,
          indexLabel: '序号',
          stripe: false,
          menuAlign: 'center',
          menu: false,
          viewBtn: false,
          editBtn: false,
          emptyBtn:false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          column: [{
            fixed: true,
            label: '主键',
            prop: 'id',
            span: 24,
            type: 'input',
            hide: true
          },{
            hide: false,
            label: '线路名称',
            prop: 'lineCode',
            type: 'select',
            filterable : true,
            formatter: function(row, value , label, column){
              return getLineName(value);
            },
            search: false,
            display: true // 动态显隐控制不能删除
          }, {
            hide: false,
            label: '站点名称',
            prop: 'stationCode',
            formatter: function(row, value , label, column){
              return getStationName(row.lineCode,value);
            },
            type: 'select',
            search: false,
            filterable : true,
            display: true// 动态显隐控制不能删除
          }, {
            label: '售票员',
            prop: 'conductorPersonName',
            search: false,
            hide: false,
          }, {
            width: 120,
            label: '售票员工号',
            prop: 'conductorPersonCode',
            search: false,
            hide: false,
          }, {
            hide: false,
            label: '设备操作号',
            prop: 'equipmentNumber',
            false: true,
          },{
            label: '收入日期',
            prop: 'settleTime',
            type: 'datetime',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            search: false
          }, {
            width: 120,
            label: 'SC售票金额',
            prop: 'sellAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'sellAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'SC充值金额',
            prop: 'investAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'investAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: 'SC补票金额',
            prop: 'faretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'faretkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: 'LC售票金额',
            prop: 'comparativeSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeSelltkAmount');
            },
            search: false,
            hide: false,
          },  {
            width: 120,
            label: 'LC充值金额',
            prop: 'comparativeInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeInvestAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'LC补票金额',
            prop: 'comparativeFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeFaretkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '充值差异金额',
            prop: 'diffInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffInvestAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '售票差异金额',
            prop: 'diffSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffSelltkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '补票差异金额',
            prop: 'diffFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffFaretkAmount');
            },
            search: false,
            hide: false,
          },{
            label: '差异类型',
            prop: 'comparativeType',
            formatter:function(row, value , label, column){
              return value == 1?'SC-LC':'LC-ACC';
            },
            search: false,
            hide: false,
          }]
        };
        this.optionTable = {
          border: false,
          index: false,
          indexLabel: '序号',
          stripe: false,
          menuAlign: 'center',
          menu: false,
          viewBtn: false,
          editBtn: false,
          emptyBtn:false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          column: [{
            width: 140,
            label: 'LC回馈售票金额',
            prop: 'replySellAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replySellAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            width: 140,
            label: 'LC回馈充值金额',
            prop: 'replyInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyInvestAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            width: 140,
            label: 'LC回馈补票金额',
            prop: 'replyFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyFaretkAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            width: 140,
            label: 'ACC回馈售票金额',
            prop: 'replyComparativeSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyComparativeSelltkAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            width: 140,
            label: 'ACC回馈充值金额',
            prop: 'replyComparativeInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyComparativeInvestAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            width: 140,
            label: 'ACC回馈补票金额',
            prop: 'replyComparativeFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyComparativeFaretkAmount');
            },
            slot:true,
            search: false,
            hide: false,
          }]
        };
        this.option={
          submitBtn:false,
          emptyBtn:false,
          group:[{
              icon:'',
              label: '',
              prop: 'group',
              column: [{
                label: '清分人员回馈差异原因',
                prop: 'qfReplyReason',
                formslot : true,
                labelWidth:200
              },{
                label: '清分人员详细描述',
                prop: 'qfReplyDetail',
                type:'textarea',
                labelWidth:180,
                disabled:this.showType==2
              }]
            }]
        }
      }
    },
    mounted() {
    }
  }
</script>
